#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int m = 0, n = 0;
	int c = 0;
	scanf("%d%d", &m, &n);
	while (c = m % n)
	{
		m = n;
		n = c;
	}
	printf("%d ", n);
	return 0;
}